#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

struct BitMapField;
struct BitMapMethod;
struct BitMap;
// 用C语言使用面对对象思想实现数据结构---位图

typedef size_t BitMap_t;
#define BITCOUNT 32

// 方法实现

typedef bool(*BitMapMethodPtr_t)(struct BitMapField*,size_t);

bool Set(struct BitMapField* field,size_t x)
{

    return false;
}

bool ReSet(struct BitMapField* field,size_t x)
{

    return false;
}

bool Test(struct BitMapField* field,size_t x)
{

    return false;
}


typedef struct BitMapMethod
{
    BitMapMethodPtr_t _set;
    BitMapMethodPtr_t _reset;
    BitMapMethodPtr_t _test;

}BitMapMethod;

typedef struct BitMapField
{
    BitMap_t* _ptr;
    size_t _size;

}BitMapField;


typedef struct BitMap
{
    BitMapField* _field;
    BitMapMethod* _method;
}BitMap;

BitMap* CreateBitMap(size_t size)
{
    BitMap* bitmap=(BitMap*)malloc(sizeof(BitMap));

    bitmap->_field=(BitMapField*)malloc(sizeof(BitMapField));
    bitmap->_method=(BitMapMethod*)malloc(sizeof(BitMapMethod));
   
    size_t count=(size>>BITCOUNT)+1;

    bitmap->_field->_ptr=(BitMap_t*)malloc(sizeof(BitMap_t)*count);
    bitmap->_field->_size=size;

    bitmap->_method->_set=&Set;
    bitmap->_method->_set=&ReSet;
    bitmap->_method->_set=&Test;

    return bitmap;
}



